//
//  GameNewsCollectionViewCell.m
//  课余时间
//
//  Created by zgr on 16/4/6.
//  Copyright © 2016年 张大少. All rights reserved.
//

#import "GameNewsCollectionViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "UIImageView+WebCache.h"
@implementation GameNewsCollectionViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
    _image_url = [[UIImageView alloc]init];
        
        _title = [UILabel new];
        _summary = [UILabel new];
        _insert_date = [UILabel new];
        _insert_date.font = [UIFont boldSystemFontOfSize:12];
        _summary.font = [UIFont boldSystemFontOfSize:12];
        _summary.textColor = [UIColor lightGrayColor];
        _insert_date.textColor = [UIColor lightGrayColor];
        _insert_date.textAlignment = NSTextAlignmentRight;
        _image_url.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:_image_url];
        [self.contentView addSubview:_title];
        [self.contentView addSubview:_summary];
        [self.contentView addSubview:_insert_date];
        
        
        
        
        
        _image_url.sd_layout
        .leftSpaceToView(self.contentView,10)
        .topSpaceToView(self.contentView,10)
        .widthIs(60)
        .heightIs(50);
        
//        _image_url.frame = CGRectMake(10, 10, 60, 50);
        _title.sd_layout
        .leftSpaceToView(_image_url,10)
        .topEqualToView (_image_url)
        .rightSpaceToView (self.contentView,10)
        .autoHeightRatio(0);
        
        _summary.sd_layout
        .leftEqualToView(_title)
        .rightEqualToView(_title)
        .topSpaceToView(_title,5)
        .autoHeightRatio(0);
        
        _insert_date.sd_layout
        .rightSpaceToView(self.contentView,5)
        .topSpaceToView(_image_url,-5)
        .widthIs(150)
        .heightIs(20);
        
        [self setupAutoHeightWithBottomViewsArray:@[_image_url,_insert_date] bottomMargin:5];
        
        
        
        
    }
    return self;
}

//-(void)setCellWithModel:(GameNewsModel *)model
//{
//    [_image_url sd_setImageWithURL:[NSURL URLWithString:model.image_url_small]];
//    _title.text = model.title;
//    _summary.text = model.summary;
//    _insert_date.text = model.insert_date;
//    
//}
-(void)setModel:(GameNewsModel *)model
{
    [_image_url sd_setImageWithURL:[NSURL URLWithString:model.image_url_small]];
    _title.text = model.title;
    _summary.text = model.summary;
    _insert_date.text = model.insert_date;

}

@end
